
import model.Game;
import model.Hockeyist;
import model.Move;
import model.Unit;
import model.World;

/**
 *
 * @author Constantine Tretyak
 */
public class Coords {

    public static final double Y_MIN = 150 + 30;
    public static final double Y_MAX = 770 - 30;
    public static final double X_MIN = 65 + 30;
    public static final double X_MAX = 1135 - 30;

    private final Hockeyist self;
    private final World world;
    private final Game gamel;
    private final Move move;
    private final double width = X_MAX - X_MIN;
    private final double height = Y_MAX - Y_MIN;

    public Coords(Hockeyist self, World world, Game gamel, Move move) {
        this.self = self;
        this.world = world;
        this.gamel = gamel;
        this.move = move;
    }

    public double getHeight() {
        return height;
    }

    public double getWidth() {
        return width;
    }

    public double getXcoord(double x) {
        if (world.getMyPlayer().getNetBack() < width / 2) {
            x = 0 - x;
        }
        return width / 2 + X_MIN + x * width / 2;
    }

    public double getYcoord(double y) {
        y = 0 - y;
        return height / 2 + Y_MIN + y * height / 2;
    }

    public double getX(double Xcoord) {
        double result = (Xcoord - (width / 2 + X_MIN)) / (width / 2);
        if (world.getMyPlayer().getNetBack() < width / 2) {
            result = 0 - result;
        }
        return result;
    }

    public double getY(double Ycoord) {
        return 0 - (Ycoord - (height / 2 + Y_MIN)) / (height / 2);
    }

    public double getQuad(Unit unit) {
        double x = getX(unit.getX());
        double y = getY(unit.getY());

        if (x >= 0 && y >= 0) {
            return 1;
        }
        if (x < 0 && y >= 0) {
            return 2;
        }
        if (x < 0 && y < 0) {
            return 3;
        }
        return 4;
    }
}
